import React, { Suspense } from "react"
import Error from "../utils/Error"
import("../utils/add").then(res => {
    // console.log(res.default)
})

let p = new Promise((resolve, reject) => {
    setTimeout(() => {
        // resolve(import(/*webpackChunkName"async"*/"./Async"))
        // reject(import(/*webpackChunkName"async"*/"./Async"))
        reject("出错了")
    }, 3000)
})
let Async = React.lazy(() => p)

class Lazy extends React.Component {
    render() {
        return (
            <fieldset>
                <legend>懒加载组件</legend>
                <h1>别动我，我很懒的</h1>
                <Error>
                    <Suspense fallback={<h1>正在加载...</h1>}>
                        <Async />
                    </Suspense>
                </Error>
            </fieldset>
        )
    }
}
export default Lazy